<admintpl file="header" />
</head>
<body>
    <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main.css?v=1.0"/>
    <script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=39721d72efafa0bdb3f511bda2a46315"></script>
    <style type="text/css">
    	#mapContainer{
    		position:relative
    	}
    </style>
    <div class="wrap js-check-wrap">
        <ul class="nav nav-tabs">
            <li><a href="{:U('Device/index')}">设备列表</a></li>
     		<li><a href="{:U('Device/inputcsv')}">导入信息</a></li>
            <li><a href="{:U('Device/add')}">添加设备</a></li>
            <li class="active"><a>修改设备</a></li>
        </ul>
        <form action="{:U('Device/edit_post')}" method="post" class="form-horizontal js-ajax-form" enctype="multipart/form-data">
            <div class="row-fluid">
                <div class="span8">
                    <table class="table table-bordered" style="margin-bottom: -1px;">
                    	<tr>
                            <th>条形码</th>
                            <td>
                                <input type="hidden" name="did" value="{$device.id}" />
                                <input type="text" readonly="readonly" value="{$device.barcode}"/>
                            </td>
                            <th>设备类型</th>
                            <td><input type="text" readonly="readonly"  value="{$btype[$device['dtype']]['name']}"/></td>
                        </tr>
                        <tr>
                            <th>设备ID</th>
                            <td>
                                <input type="text" name="devid" value="{$device.devid}" placeholder="请输入设备ID"/>
                            </td>
                            <th>设备UUID</th>
                            <td>
                                <input type="text" name="uuid" value="{$device.uuid}" placeholder="请输入设备UUID"/>
                            </td>
                        </tr>
                        <tr>
                            <th>major值</th>
                            <td>
                                <input type="text" name="major" value="{$device.major}" placeholder="请输入major值"/>
                            </td>
                            <th>minor值</th>
                            <td>
                                <input type="text" name="minor" value="{$device.minor}" placeholder="请输入minor值"/>
                            </td>
                        </tr>
                        <tr>
                            <th>设备状态</th>
                            <td>
                                <select name="status">
                                    <foreach name="bstatus" item="vo">
                                        <option value="{$vo.id}"<if condition="$vo['id'] eq $device['status']" >selected </if>>{$vo.name}</option>
                                    </foreach>
                                </select>
                            </td>
                            <th>备注</th>
                            <td>
                                <input type="text" name="remark" value="{$device.remark}" placeholder="请输入备注"/>
                            </td>
                        </tr>
                        <tr>
                            <th>激活日期</th>
                            <td>
                                <input type="text" readonly="readonly" value="{$device.livetime}"/>
                            </td>
                            <th>更新日期</th>
                            <td>
                                <input type="text" readonly="readonly"  value="{$device.updatetime}"/>
                            </td>
                        </tr>
                        <if condition="$store" >
                        <tr>
                            <th>店铺名称</th>
                            <td>{$store.title}</td>
                            <th>子名称</th>
                            <td>{$store.title_branch}</td>
                        </tr>
                        <tr>
                            <th>店铺地址</th>
                            <td>{$store.address}</td>
                            <th>店铺类型</th>
                            <td>{$stype[$store['stype']]['name']}</td>
                        </tr>
                        <tr>
                            <th>创建日期</th>
                            <td>{$store.add_time}</td>
                            <th>更新日期</th>
                            <td>{$store.update_time}</td>
                        </tr>
                        <tr>
                            <th>设备坐标(经)</th>
                            <td>{$store.longitude}</td>
                            <th>设备坐标(纬)</th>
                            <td>{$store.latitude}</td>
                        </tr>
                    	<tr>
                            <th>分店店长</th>
                            <td>
                            <foreach name="susers" item="vo">
								<if condition="$vo['oid'] eq $store['user_id']">
									{$vo.realname} - {$vo.mobile}
								</if>
                            </foreach>
                            </td>
                            <th>总店店长</th>
                            <td>
                            <foreach name="susers" item="vo">
								<if condition="$vo['oid'] eq $store['owner_id']">
									{$vo.realname} - {$vo.mobile}
								</if>
                            </foreach>
                        </tr>
                    	<tr>
                            </td>
                            <th>市场人员</th>
                            <td>
                            <foreach name="susers" item="vo">
								<if condition="$vo['oid'] eq $store['marketing_id']">
									{$vo.realname} - {$vo.mobile}
								</if>
                            </foreach>
                            </td>
                            <th>经销商</th>
                            <td>
                            <foreach name="susers" item="vo">
								<if condition="$vo['oid'] eq $store['agency_id']">
									{$vo.realname} - {$vo.mobile}
								</if>
                            </foreach>
                            </td>
                       </tr>
                    	<tr>
                            <th>签约人员</th>
                            <td>
                            <foreach name="susers" item="vo">
								<if condition="$vo['oid'] eq $store['sign_user_id']">
									{$vo.realname} - {$vo.mobile}
								</if>
                            </foreach>
                            </td>
                            <th>省 - 市 - 区</th>
                            <td>
                            <foreach name="region" item="vo">
								<if condition="$vo['code'] eq $store['province_id']">
									{$vo.name}
								</if>
                            </foreach>
                            -
                            <foreach name="region" item="vo">
								<if condition="$vo['code'] eq $store['city_id']">
									{$vo.name}
								</if>
                            </foreach>
                            -
                            <foreach name="region" item="vo">
								<if condition="$vo['code'] eq $store['district_id']">
									{$vo.name}
								</if>
                            </foreach>
                            </td>
                        </tr>
                        </if>
                    </table>
                </div>
    		<div class="span4">
				<table width="100%"  cellpadding="2" cellspacing="2" class="table table-bordered">
						<tr><td><b>地图信息</b></td></tr>
						<tr><td style="height:207px;"><div id="mapContainer"></div></td></tr>
						<if condition="$device['loding']">
						<tr><td>
							<b>Loding</b>
							<if condition="$device['loding']">
								<a style="float: right;" href="{:U('Device/remove_loding', array('id'=>$device['id']))}" class="js-ajax-dialog-btn" data-msg="你确定移除Loding图吗？">移除Loding</a>
							</if>
						</td></tr>
						<tr><td><img src="{$urlimg}{$device.loding}"></td></tr>
						</if>
				</table>
			</div>
            </div>
            <div class="form-actions">
                <button class="btn btn-primary js-ajax-submit" type="submit">提交</button>
                <a class="btn" href="{:U('Device/index')}">返回</a>
            </div>
        </form>
    </div>
    <script type="text/javascript" src="__PUBLIC__/js/common.js"></script>

<script type="text/javascript">
    var infoWindow;
    //初始化地图对象，加载地图
    var map = new AMap.Map("mapContainer", {
        resizeEnable: true,
        zoom: 15,
        center:[{$store.longitude},{$store.latitude}]
    });

    addMarker();
    //添加marker标记
    function addMarker() {
        map.clearMap();
        var marker = new AMap.Marker({
            map: map,
            //位置
            position: [{$store.longitude},{$store.latitude}]
        });
        //鼠标点击marker弹出自定义的信息窗体
        AMap.event.addListener(marker, 'click', function() {
            infoWindow.open(map, marker.getPosition());
        });
    }
    //在指定位置打开信息窗体
    function openInfo() {
        //构建信息窗体中显示的内容
        var info = [];
        info.push("<div style=\"padding:0px 0px 0px 4px;\"><b>{$store.title}({$store.title_branch})</b>");
        info.push("地址 : {$store.address}</div>");

        infoWindow = new AMap.InfoWindow({
            content: info.join("<br/>"),  //使用默认信息窗体框样式，显示信息内容
        	offset: new AMap.Pixel(0, -15)//-113, -140
        });
        infoWindow.open(map, [{$store.longitude},{$store.latitude}]);
    }
    openInfo();
</script>
</body>
</html>
